using com.shinian.fcg.fbs;
using FCGGameConfig = com.shinian.fcg.fbs.GameConfig;
using GF.Debug;
using System.Collections.Generic;

public class StaticDataMgr : MonoSingleton<StaticDataMgr>
{
    private Dictionary<int, FxData> fxDataCache;
    public Dictionary<int, FxData> FxDataCache
    {
        get
        {
            return fxDataCache;
        }

        set
        {
            fxDataCache = value;
        }
    }
    private Dictionary<int, GuideGroup> guideGroupCache;

    public Dictionary<int, GuideGroup> GuideGroupCache
    {
        get
        {
            return guideGroupCache;
        }

        set
        {
            guideGroupCache = value;
        }
    }

    public void LoadData(FCGGameConfig? config)
    {
        //加载引导表
        if(guideGroupCache == null)
        {
            guideGroupCache = new Dictionary<int, GuideGroup>();
        }
        guideGroupCache.Clear();
        for (int i = 0; i < config.Value.GuideConfig.Value.GuideGroupLength; i++)
        {
            var group = config.Value.GuideConfig.Value.GuideGroup(i);
            if (!guideGroupCache.ContainsKey(group.Value.Rid))
            {
                guideGroupCache.Add(group.Value.Rid, group.Value);
            }
            else
            {
                Debugger.LogError("引导数据重复" + group.Value.Rid);
            }
        }

        //加载特效表
        if (fxDataCache == null)
        {
            fxDataCache = new Dictionary<int, FxData>();
        }
        fxDataCache.Clear();
        for (int i = 0; i < config.Value.FxConfig.Value.FxDataLength; i++)
        {
            var fxdata = config.Value.FxConfig.Value.FxData(i);
            if (!fxDataCache.ContainsKey(fxdata.Value.Id))
            {
                fxDataCache.Add(fxdata.Value.Id, fxdata.Value);
            }
            else
            {
                Debugger.LogError("特效数据重复" + fxdata.Value.Id);
            }
        }
    }
}
